package deepclone.clone;

/**
 * @author: knowno
 * @create: 2025-09-12 13:49
 * @Version 1.0
 **/
public class TestBoyClone {
    public static void main(String[] args) throws CloneNotSupportedException {
        //创建一个Boy
        Boy boy = new Boy();
        //设置属性
        boy.setName("张三");
        boy.setAge(18);
        //创建一个Girl
        Girl girl = new Girl();
        //设置属性
        girl.setName("小白");
        girl.setAge(18);
        //设置关系
        boy.setGirl(girl);
        System.out.println("boy :" + boy);

        //克隆
        Boy boyclone = (Boy) boy.clone();
        //打印
        System.out.println("boy clone :" + boyclone);

        System.out.println("**************************************************");
        //深 测试 =>修改克隆对象中girl的name属性
        boyclone.getGirl().setName("小红");
        //打印
        System.out.println("boy :" + boy);
        //打印
        System.out.println("boy clone :" + boyclone);


    }
}
